#include<fcntl.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>

int main()
{
	char buf[1000];
	int fd=open("./1.txt",O_RDWR);
	if(fd==-1)
	{
		printf("打开失败\n");
		perror("open");
		return -1;
	}
	else
	{
		printf("打开成功\n");
		
		int wrt = write(fd, buf, sizeof(buf));
		if(wrt==-1)
		{
			perror("write");
			return -1;
		}
		buf[wrt] = '\0';
		printf("wrt=%d buf=%s\n",wrt,buf);
		
		close(fd);
	}

}

